﻿using System;
using UnityEngine;
using Object = UnityEngine.Object;

namespace GameLauncher.Runtime
{
    public static class HotFixUI
    {
        /// <summary>
        /// 初始化。
        /// </summary>
        public static void Initialize()
        {
            if (mInit)
                return;
            mHotFixUIWindow = Object.Instantiate(Resources.Load<HotFixUIWindow>("Prefabs/HotFixUI"));
            mInit = true;
        }

        /// <summary>
        /// 初始化。
        /// </summary>
        public static void Release()
        {
            if (!mInit)
                return;
            Object.Destroy(mHotFixUIWindow.gameObject);
            mInit = false;
        }


        public static void ShowOneMessageBox(string desc, Action btnAction)
        {
            if (!mInit)
                return;
            mHotFixUIWindow.ShowOneMessageBox(desc, btnAction);
        }

        public static void ShowTwoMessageBox(string desc, Action sureBtnAction, Action cancelBtnAction)
        {
            if (!mInit)
                return;
            mHotFixUIWindow.ShowTwoMessageBox(desc, sureBtnAction, cancelBtnAction);
        }

        /// <summary>
        /// 下载进度更新
        /// </summary>
        /// <param name="progress"></param>
        public static void RefreshDownProgress(float progress)
        {
            if (!mInit)
                return;
            mHotFixUIWindow.RefreshDownProgress(progress);
        }

        /// <summary>
        /// 下载进度完成
        /// </summary>
        /// <param name="type"></param>
        public static void RefreshDownloadComplete()
        {
            if (!mInit)
                return;
            mHotFixUIWindow.RefreshDownloadComplete();
        }

        /// <summary>
        /// 刷新描述信息
        /// </summary>
        /// <param name="desc"></param>
        public static void RefreshDescLabel(string desc)
        {
            if (!mInit)
                return;
            mHotFixUIWindow.RefreshDescLabel(desc);
        }

        /// <summary>
        /// 刷新版本信息
        /// </summary>
        public static void RefreshVersion()
        {
            if (!mInit)
                return;
            mHotFixUIWindow.RefreshVersion();
        }
        
        
        private static HotFixUIWindow mHotFixUIWindow;
        private static bool mInit = false;
    }
}